package com.appkubes.fintech.admin.application.repair;


import com.appkubes.fintech.admin.application.repair.request.RepairOrderInfoRequest;
import com.appkubes.fintech.admin.application.repair.response.RepairOrderInfoResponse;
import com.appkubes.fintech.admin.application.repair.service.RepairOrderInfoService;
import com.appkubes.fintech.common.response.Response;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/*
 *
 * @author xqc
 * @date 	2020/02/05 10:51:16
 */
@RestController
@RequestMapping("repair/repairOrderInfo")
@Api(tags = "维修订单", value = "RepairOrderInfoController")
@Slf4j
public class RepairOrderInfoController {

    @Autowired
    private RepairOrderInfoService repairOrderInfoService;


    @ApiOperation(tags = "分页维修订单", value = "queryPage")
    @PostMapping(value = "queryPage")
    public Response<PageInfo<RepairOrderInfoResponse>> queryPage(@RequestBody RepairOrderInfoRequest repairOrderInfoRequest) {

        PageInfo<RepairOrderInfoResponse> pageInfo = repairOrderInfoService.queryPage(repairOrderInfoRequest);
        return Response.success(pageInfo);
    }

//    @ApiOperation(tags = "新增维修订单", value = "save")
//    @PostMapping(value = "save")
//    public Response save(@RequestBody RepairOrderInfoRequest repairOrderInfoRequest) {
//
//        return repairOrderInfoService.save(repairOrderInfoRequest);
//
//    }

    @ApiOperation(tags = "更新维修订单", value = "update")
    @PostMapping(value = "update")
    public Response update(@RequestBody RepairOrderInfoRequest repairOrderInfoRequest) {

        return repairOrderInfoService.update(repairOrderInfoRequest);
    }

    @ApiOperation(tags = "删除维修订单", value = "delete")
    @PostMapping(value = "delete")
    public Response delete(String id) {
        return repairOrderInfoService.deleteRepairOrderInfo(id);
    }

    @ApiOperation(tags = "获取维修订单", value = "getById")
    @GetMapping(value = "getById")
    public Response<RepairOrderInfoResponse> getById(String id) {
        Response res=  repairOrderInfoService.getById(id);

        return res;
    }

    @ApiOperation(tags = "维修订单评估", value = "approval")
    @PostMapping(value = "approval")
    public Response<RepairOrderInfoResponse> approval(@RequestBody RepairOrderInfoRequest request) {
        Response res=  repairOrderInfoService.approval(request);

        return res;
    }


}
